<?php

namespace App\Notifications\Wechat;

use App\Internals\UserInternal;
use Illuminate\Support\Facades\Log;

class LessonStart extends Notification
{
    public function notify($userId, $lessonName, $lessonSeq, $courseLevel, $datetime, $seriesName)
    {
        $templateId = 'JyxGrsw6QcHcArxvyOQK7zw1eVf-GAQVLJ55OJ0TgcE';
        $socialAccount = UserInternal::getSocialAccount($userId);
        $url = config('app.base_url') . '/?#/menu/course';

        $data = [
            'first'    => sprintf("%s 家长您好，今天晚上%s将为您的宝贝推送新绘本《%s》，请预留阅读时间哦！\n", $socialAccount['nickname'], date('H:i', strtotime($datetime)), $lessonName),
            'keyword1' => [sprintf('%s - Level%s课程', $seriesName, $courseLevel), '#FF6F6F'],
            'keyword2' => [sprintf('Lesson %s 《%s》', $lessonSeq, $lessonName), '#FF6F6F'],
            'keyword3' => ['北美外教', '#FF6F6F'],
            'keyword4' => [$datetime . "\n", '#FF6F6F'],
            'remark'   => ['点击了解详情，记得准时阅读哦！', '#FF6F6F'],
        ];
        $this->send($socialAccount['openId'], $templateId, $url, $data);
        Log::info('lessonStart notify success');
    }
}
